<template>
  <div id="app">
    <transition name="fade">
      <router-view />
    </transition>
  </div>
</template>

<script>

export default {
  name: "app",
  created() {
    this.$socket.emit('vuelogin', {username: localStorage.getItem('uid')})
  },
  mounted(){
    this.sockets.subscribe('toone', (data) => {
      this.$store.commit('messlist', data)
      if(this.$store.state.sendmessagelist.length===0){
        console.info('message',data.message)
        this.$store.commit('setlist',data)
      }else {
        this.$store.commit('replace',
          {...data})
      }
    });
    window.addEventListener('beforeunload', e => this.beforeunloadHandler(e))
  },
  methods:{
    beforeunloadHandler (e) {
      console.info('页面刷新')
      
    },
    async getform(list){
      try {
        const res = await this.$axios({
          url:'/blog/userfindall',
          method:"post",
          data:{
            uid: parseInt(list.from),
          }
        })
        const { success, data, msg } = res.data
        if( success ){
          list.data = data[0]
        }
      }catch (e) {

      }
    }
  }
}
</script>

<style lang="scss">
html{
  width: 100%;
  height: 100%;
  background: url(./assets/bac.jpg)center;
  background-size: cover;
}
body{
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
}
#app{
  padding: 0;
  margin: 0;
  width: 100%;
  height: 100%;
}
.fade-enter-active, .fade-leave-avtive {
  transition: all 0.5s ;
}
.fade-enter, .fade-leave-to {
  opacity: 0;
  -webkit-transform: translate(0, vw(100));
  transform: translate(0, vw(100));

}

</style>
